<template>
  <div class="topic">
      <p class="title">拆二代的美好生活</p>
      <div class="content">我们这些非拆二代是不懂的</div>
      <comment-list></comment-list>
  </div>
</template>

<script>
import { defineAsyncComponent } from 'vue';


function fn(){
    // 为 Promise 构造函数指定一个执行器
    let executor = (resolve, reject) => {
        function toDo(){
            resolve( import('@/views/CommentListView.vue') );
        }
        setTimeout(  toDo , 5000 );
    }
    // 创建 Promise 实例
    let p = new Promise( executor );
    return p ;
}

// let fn = () => import('@/views/CommentListView.vue');

export default {
    name: 'TopicView',
    components: {
        // Vue 提供了一个 defineAsyncComponent 函数用于定义异步组件
        'comment-list' : defineAsyncComponent( fn )
    },
    created(){
        console.log('已创建TopicView组件');
    }
}
</script>

<style>

</style>